GetConsumingEnumerable Method (CancellationToken)

Task Parallel System.Threading

Provides a consuming IEnumerable<(Of <(T>)>) for items in the collection. Calling MoveNext on the returned enumerable will block if there is no data available, or will throw an OperationCanceledException if the CancellationToken is canceled.

Namespace:  System.Collections.Concurrent
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Function GetConsumingEnumerable ( _
	cancellationToken As CancellationToken _
) As IEnumerable(Of T)
C#
public IEnumerable<T> GetConsumingEnumerable(
	CancellationToken cancellationToken
)

Parameters

cancellationToken
Type: System.Threading..::.CancellationToken
A cancellation token to observe.

Return Value

An IEnumerable<(Of <(T>)>) that removes and returns items from the collection.

Exceptions

ExceptionCondition
System..::.ObjectDisposedExceptionThe BlockingCollection<(Of <(T>)>) has been disposed.
System..::.OperationCanceledExceptionIf the CancellationToken is canceled.

See Also